<!--
 * @Author: HeAo
 * @Date: 2021-10-11 14:13:17
 * @LastEditTime: 2021-10-11 14:54:47
 * @LastEditors: HeAo
 * @Description: 
 * @FilePath: \web2103-2105\web2103code\3-2-Vue\day03\1-组件基础.html
 * 别乱动！
-->
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>vue组件技术</title>
  <script src="../js/vue.js"></script>
</head>

<body>
  <div id="app">
    <my-com></my-com>
    <my-com></my-com>
    <my-com></my-com>
    <my-com></my-com>
    <my-com></my-com>
    <my-com></my-com>
    <!-- <my-com2></my-com2> -->
  </div>
  <script>
    // 1.组件的定义
    let component1 = {
      data() {
        return {
          msg: '我是子组件一'
        }
      },
      // data: {
      //   msg: '我是子组件一'
      // },
      template: `
        <div>
          <h3>{{msg}}</h3>
          <button @click="msg = '新数据'">修改数据</button>
        </div>
      `
    }

    let component2 = {
      data() {
        return {
          msg: '我是子组件二'
        }
      },
      template: `
        <div>
          <h3>{{msg}}</h3>
        </div>
      `
    }

    // 2.组件注册
    // 2.1全局注册
    Vue.component('my-com', component1)

    let vm = new Vue({
      el: '#app',
      data: {},
      methods: {},
      created() { },
      components: {
        'my-com2': component2
      }
    })
  </script>
</body>

</html>